package com.sgl.util;

import com.github.qcloudsms.SmsMultiSender;
import com.github.qcloudsms.SmsMultiSenderResult;
import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException;
import org.json.JSONException;
import java.io.IOException;
import java.net.SocketPermission;

public class CloudSmsUtil {

    private static int appid=1400347802;
    private static String appkey="666207b9c2a180c1a2db8e92b74492d2";
    private static int templateId=588573;
    private static String smsSign="星火环球";

    public static SmsSingleSenderResult send(String phoneNumbers,String[] params){
        SmsSingleSenderResult result=null;
        try {
            SmsSingleSender ssender = new SmsSingleSender(appid, appkey);
             result = ssender.sendWithParam("86", phoneNumbers, templateId, params, smsSign, "", "");  // 签名不能为空串
            System.out.println(result);
            return result;
        } catch (HTTPException e) {
            // HTTP响应码错误
            e.printStackTrace();
            return result;

        } catch (JSONException e) {
            // json解析错误
            e.printStackTrace();
            return result;
        } catch (IOException e) {
            // 网络IO错误
            e.printStackTrace();
            return result;
        }

    }

    public static void main(String[] args) {
        String[] param=new String[2];

        param[0]="123";
        param[0]="https://sgl.sglpay.com网址";
        System.out.printf(param[0]);
        String[] params={"1233"};
        System.out.println(CloudSmsUtil.send("15159867747",params));
    }




}
